#include "stdafx.h"
#include "SmallObject.h"

#include "SmallObj.h"

using namespace Loki;

typedef SmallObjectBase< DEFAULT_THREADING, DEFAULT_CHUNK_SIZE*2,
512, LOKI_DEFAULT_OBJECT_ALIGNMENT, Loki::PhoenixSingleton > SmallObjBase;

typedef SmallObjectBase< DEFAULT_THREADING, DEFAULT_CHUNK_SIZE*2,
MAX_SMALL_OBJECT_SIZE, LOKI_DEFAULT_OBJECT_ALIGNMENT, Loki::PhoenixSingleton > SmallValueBase;

namespace SO
{
	
	UE_IMPLEMENT_DYNAMIC(SmallObject, Object_); 
		
	void * SmallObject::operator new ( size_t size )
	{
#if	defined(_ARXDEBUG) || defined(_DEBUG)
		return ::operator new(size);
#else
		return SmallObjBase::operator new(size);
#endif
	}
	
	void * SmallObject::operator new ( size_t size, const std::nothrow_t & t) throw ()
	{
#if	defined(_ARXDEBUG) || defined(_DEBUG)
		return ::operator new(size, t);
#else
		return SmallObjBase::operator new(size, t);
#endif
	}
	
	void SmallObject::operator delete ( void * p, size_t size ) throw ()
	{
#if	defined(_ARXDEBUG) || defined(_DEBUG)
		::operator delete(p);
#else
		SmallObjBase::operator delete(p, size);
#endif
	}
	
	void SmallObject::operator delete ( void * p, size_t size,
		const std::nothrow_t &t ) throw()
	{
#if	defined(_ARXDEBUG) || defined(_DEBUG)
		::operator delete(p);
#else
		SmallObjBase::operator delete(p, size, t);
#endif
	}
	
#ifdef _DEBUG
		void * SmallObject::operator new ( size_t nSize, LPCSTR lpszFileName, int nLine )
		{
			return ::operator new ( nSize, lpszFileName, nLine );
		}

		void SmallObject::operator delete ( void * p, size_t size, LPCSTR lpszFileName, int nLine )
		{
			::operator delete ( p );
		}
#endif
}

namespace SV
{
	void * SmallValueObject::operator new ( size_t size )
	{
#if	defined(_ARXDEBUG) || defined(_DEBUG)
		return ::operator new(size);
#else
		return SmallValueBase::operator new(size);
#endif
	}

	UE_IMPLEMENT_DYNAMIC(SmallValueObject, Object_);
	void * SmallValueObject::operator new ( size_t size, const std::nothrow_t & t) throw ()
	{
#if	defined(_ARXDEBUG) || defined(_DEBUG)
		return ::operator new(size, t);
#else
		return SmallValueBase::operator new(size, t);
#endif
	}
	
	void SmallValueObject::operator delete ( void * p, size_t size ) throw ()
	{
#if	defined(_ARXDEBUG) || defined(_DEBUG)
		::operator delete(p);
#else
		SmallValueBase::operator delete(p, size);
#endif
	}
	
	void SmallValueObject::operator delete ( void * p, size_t size,
		const std::nothrow_t &t ) throw()
	{
#if	defined(_ARXDEBUG) || defined(_DEBUG)
		::operator delete(p);
#else
		SmallValueBase::operator delete(p, size, t);
#endif
	}
	
#ifdef _DEBUG
	void * SmallValueObject::operator new ( size_t nSize, LPCSTR lpszFileName, int nLine )
	{
		return ::operator new ( nSize, lpszFileName, nLine );
	}
	
	void SmallValueObject::operator delete ( void * p, size_t size, LPCSTR lpszFileName, int nLine )
	{
		::operator delete ( p );
	}
#endif
}